import os

from django.utils.translation import ugettext as _
from django.core.exceptions import ValidationError


def validate_file_extension(value):
    """Used for certifying the extension of uploaded file"""
    ext = os.path.splitext(value.name)[1]
    valid_extensions = ('.cert', )

    if not ext.lower() in valid_extensions:
        raise ValidationError(_("Unsupported file extension"))
